package 迭代器;

import java.util.Iterator;
import java.util.List;

// implements Iterator<DepartMent> （最后写上好，这样Next 直接返回Department对象）
public class ComputerCollegeIterator implements Iterator<DepartMent> {

    private List<DepartMent> lists;
    int index = -1;

    public ComputerCollegeIterator(List<DepartMent> lists) {
        this.lists = lists;
    }

    @Override
    public boolean hasNext() {
        if (index < lists.size() - 1){
            index ++;
            return true;
        }
        else
            return false;
    }

    @Override
    public DepartMent next() {
        return lists.get(index);
    }
}
